<?php

namespace App\Model;

use Illuminate\Database\Eloquent\Model;

class Move_task extends Model
{
    //
	protected $table='move_task';
	protected $guarded=[];
	protected $hidden=[];


	public function no_lists($store_id){
		return $this->where(['to_store_id'=>$store_id,'status'=>0])->with('store')->with('store_station')->get();
	}

	//调入部门
	public function store(){
		return $this->belongsTo('App\Model\Store','to_store_id');
	}

	//支援岗位
	public function store_station(){
		return $this->belongsTo('App\Model\Store_station','to_store_station_id');
	}


	//调出人员
	public function from_staff(){
		return $this->belongsTo('App\Model\Staff','from_staff_id');
	}

	//调出部门
	public function from_store(){
		return $this->belongsTo('App\Model\Store','from_store_id');
	}

//	获取所有的临时调动审批的列表
	public function lists($company_id){
		return $data=$this->where(['company_id'=>$company_id])->get();
	}

//	更新任务
	public function update_desc($data){
		return $this->where(['id'=>$data['id']])->update($data);
	}

	public function task_desc($id){
		$data=$this->where(['id'=>$id])->with('store_station')
			->with('store')->with('from_staff')->with('from_store')
			->first();
		return $data;
	}
}
